#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
#define int long long
int n,a[114],b[114],m;
int pw(int x,int y){
	y%=(mod-1);
	int ans=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) ans=ans*x%mod;
	return ans;
}
int get(int k,int q){
	if(k<0) return 0;
	return (1-pw(q,k+1)+mod)%mod*pw(1+mod-q,mod-2)%mod;
}
int f[5500];
signed main(){
	freopen("yt.in","r",stdin);
	freopen("yt.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;++i) cin>>a[i]>>b[i];
	if(n==1) return cout<<pw(a[1],m)%mod,0;
	if(n==2){
		int l=max(0ll,m-b[2]),r=min(b[1],m),inv=a[1]*pw(a[2],mod-2)%mod;
		cout<<(get(r,inv)-get(l-1,inv)+mod)*pw(a[2],m)%mod;
		return 0;
	}
	f[0]=1;
	for(int i=1;i<=n;++i)
	for(int j=m;j;--j)
	for(int k=1,w=a[i];k<=b[i]&&k<=j;++k,w=w*a[i]%mod) (f[j]+=f[j-k]*w)%=mod;
	cout<<f[m];
	return 0;
}


